<? if ($c = stack('name')) {

	$d = component_data($c);
	$s = component_settings($c);
	
addScriptLink("http://api-maps.yandex.ru/1.0/?key=$s[api_key]"); startScript('jquery'); ?><script type="text/javascript">

jQuery( function($) {

	function iMapa(id, data) {
		this.id = id;
		this.data = data;
		
		this.style = {hideIcon:true, style: "kk#customPoint"};
		
		this.map = new YMaps.Map( document.getElementById(id) );
	
		this.map.setCenter(new YMaps.GeoPoint(<?=$s['map_center']?>), <?=$s['map_scale']?>, YMaps.MapType.MAP);
		
		this.map.addControl(new YMaps.Zoom());
		this.map.addControl(new YMaps.ToolBar());
		this.map.addControl(new YMaps.TypeControl());
		this.map.enableScrollZoom();
		
		var t = new YMaps.Template();
		t.text = '<?=quot_safe($s['balloon_tpl'])?>';
		YMaps.Templates.add("kk#balloon", t);
	
	
		var s = new YMaps.Style();
		s.iconStyle = new YMaps.IconStyle("kk#customPointIcon");
		s.iconStyle.offset = new YMaps.Point(<?=$s['point_offset']?>);
		s.iconStyle.href = "<?=$s['point_url']?>";
		s.iconStyle.size = new YMaps.Point(<?=$s['point_size']?>);
		s.iconStyle.shadow = new YMaps.IconShadowStyle();
		s.iconStyle.shadow.offset = new YMaps.Point(<?=$s['shadow_offset']?>);
		s.iconStyle.shadow.href = "<?=$s['shadow_url']?>";
		s.iconStyle.shadow.size = new YMaps.Point(<?=$s['shadow_size']?>);
		
		s.balloonContentStyle = new YMaps.BalloonContentStyle("kk#balloon");
		YMaps.Styles.add("kk#customPoint", s);
	
		var t = new YMaps.Template();
		t.text = "<div><img style=\"height:$[style.iconStyle.size.y];width:$[style.iconStyle.size.x];\" src=\"$[style.iconStyle.href]\"\/></div>";
		YMaps.Templates.add("kk#customPointIcon", t);
		
		
		var placemark;
		for (var i in this.data) {
			placemark = new YMaps.Placemark(this.data[i].point, this.style);
			placemark.kk = this.data[i];
			this.map.addOverlay(placemark);
		}
	
	
	}

	
	xMapa = new iMapa("<?=$s['map_id']?>", { <?
		$i = 0;
		$temp = array();
		
		foreach ((array)$d as $v) {
			$temp1 = array("point: new YMaps.GeoPoint($v[coords])");
			
			foreach ((array)$v['data'] as $k => $v)
				$temp1[] = "$k: \"".h($v)."\"";
				
			$i++;
			$temp[] = "$i:{".implode(',', $temp1)."}";
		}
		
		?><?=implode(',', $temp)?><?
	?> });
	
});

</script><?	endScript();


	?><div id="<?=$s['map_id']?>"></div><?

	unstack();
}